function relTeacher(){
	$('#basic').modal().show();
}

var tchData = {
	iTotalRecords : 99,// (页面过滤)过滤前总记录数.总记录,之前过滤(即数据库中记录的总数)
	iTotalDisplayRecords : 99,// (页面过滤)过滤后总记录数.总记录,之后过滤(即过滤后记录的总数已经应用——不仅仅是记录的数量返回结果集)
	iTotalPages : 10,// 总页数
	sEcho : 101,// 页面发来的参数，原样返回
	aaData:[{name:'李佳佳',mobile:'18812345678',createTime:'2017-05-31 12:13:15',id:1},{name:'王耍耍',mobile:'18887654321',createTime:'2017-05-31 12:13:15',id:2}]
};


////////////
// 结果集
var modalVue = new Vue({
	el: '.modal',
	data: {
		items:[],
		ids:[],
		curPage:1,
		totalPages:0,
		totalRecords:0,
		pageRecords:25,
		condition:{
			search_LIKE_groupName:'',
			iDisplayStart:0,
			iDisplayLength:25
		}
	},
	methods:{
		search:function(){
			this.condition.iDisplayStart = this.start;
        	this.condition.iDisplayLength = this.pageRecords;
        	
        	modalVue.binding(tchData.aaData,tchData.iTotalPages,tchData.iTotalRecords);
        	return;
        	
			$.getData({//提交数据
				url:'school/student/contact',//直接写除掉项目名之后的路径
				data:this._data.condition,//获取vue绑定的数据，一定要用_data获取，不要直接提交pageData，否则会导致浏览器
				success:function(res){//服务端返回成功的回调
					if(res.data){
						modalVue.binding(res.data.aaData,res.data.iTotalPages,res.data.iTotalRecords);
					}
				},
				error:function(data){//返回错误的调
					
				}
			});
		},
		del:function(item){
			$.post({
				url:'brush/buyer/delete/'+item.id,
				data:{},
				success:function(res){//服务端返回成功的回调
					modalVue.search();
				},
				error:function(data){//返回错误的调
					
				}
			});
		},
		reset:function(){
			this.condition.search_LIKE_email='';
			this.condition.search_GTE_inDate='';
			this.condition.search_LTE_inDate='';
		},
		binding:function(data,tp,tr){
    		// 数据绑定
			this.items = data;
			this.totalPages = tp;
			this.totalRecords = tr;
    	},
        btnClick: function(data){
        	// 点击页码
        	if(isNaN(parseInt(data))) return;
            if(data != this.curPage){
                this.curPage = data
            };
             this.search();
        },
        firstClick:function(){
        	// 第一页
        	if(this.curPage > 1){
        		this.curPage = 1;
        	};
        	this.search();
        },
        prevClick:function(){
        	// 上一页
        	if(this.curPage > 1){
        		this.curPage--;
        	};
        	this.search();
        },
        nextClick:function(){
        	// 下一页
        	if(this.curPage < this.totalPages){
        		this.curPage++;
        	};
        	this.search();
        },
        lastClick:function(){
        	// 最后一页
        	if(this.curPage != this.totalPages){
        		this.curPage = this.totalPages;
        	}
        },
        submit:function(){
			// 查询提交
        	this.search();
		},
		reset:function(){
			// 重置查询条件
		}
	},
	computed: {
    	start:function(){
    		// 开始条数
    		return (this.curPage -1) * this.pageRecords + (this.items.length > 0 ? 1 : 0);
    	},
    	end:function(){
    		// 结束条数
    		return (this.curPage -1) * this.pageRecords + this.items.length;
    	},
    	indexs: function(){
        	// 显示的页码
            var left = 1
            var right = this.totalPages
            var ar = [] 
            if(this.totalPages >= 11){
              if(this.curPage > 5 && this.curPage < this.totalPages - 4){
                      left = this.curPage - 5
                      right = this.curPage + 4
              }else{
                  if(this.curPage <= 5){
                      left = 1
                      right = 10
                  }else{
                      right = this.totalPages
                      left = this.totalPages - 9
                  }
              }
           }
          while (left <= right){
              ar.push(left)
              left ++
          }   
          return ar
       },
       disableLast: function(){
    	   // 是否禁用最后页按钮
            if(this.curPage == this.totalPages){
                return true
            }
            return false
       },
       disableFirst: function(){
    	   // 是否禁用第一页按钮
            if(this.curPage == 1){
                return true
            }
           return false
       }
	}
});
modalVue.search();

//////////////////部门教职工列表
// 结果集
var appVue = new Vue({
	el: '#app',
	data: {
		items:[],
		curPage:1,
		totalPages:0,
		totalRecords:0,
		pageRecords:25,
		condition:{
			search_LIKE_groupName:'',
			iDisplayStart:0,
			iDisplayLength:25
		}
	},
	methods:{
		search:function(){
			this.condition.iDisplayStart = this.start;
        	this.condition.iDisplayLength = this.pageRecords;
        	
        	appVue.binding(tchPageData.aaData,tchPageData.iTotalPages,tchPageData.iTotalRecords);
        	return;
        	
			$.getData({//提交数据
				url:'school/student/contact',//直接写除掉项目名之后的路径
				data:this._data.condition,//获取vue绑定的数据，一定要用_data获取，不要直接提交pageData，否则会导致浏览器
				success:function(res){//服务端返回成功的回调
					if(res.data){
						appVue.binding(res.data.aaData,res.data.iTotalPages,res.data.iTotalRecords);
					}
				},
				error:function(data){//返回错误的调
					
				}
			});
		},
		del:function(item){
			$.post({
				url:'brush/buyer/delete/'+item.id,
				data:{},
				success:function(res){//服务端返回成功的回调
					appVue.search();
				},
				error:function(data){//返回错误的调
					
				}
			});
		},
		reset:function(){
			this.condition.search_LIKE_email='';
			this.condition.search_GTE_inDate='';
			this.condition.search_LTE_inDate='';
		},
		binding:function(data,tp,tr){
    		// 数据绑定
			this.items = data;
			this.totalPages = tp;
			this.totalRecords = tr;
    	},
        btnClick: function(data){
        	// 点击页码
        	if(isNaN(parseInt(data))) return;
            if(data != this.curPage){
                this.curPage = data
            };
             this.search();
        },
        firstClick:function(){
        	// 第一页
        	if(this.curPage > 1){
        		this.curPage = 1;
        	};
        	this.search();
        },
        prevClick:function(){
        	// 上一页
        	if(this.curPage > 1){
        		this.curPage--;
        	};
        	this.search();
        },
        nextClick:function(){
        	// 下一页
        	if(this.curPage < this.totalPages){
        		this.curPage++;
        	};
        	this.search();
        },
        lastClick:function(){
        	// 最后一页
        	if(this.curPage != this.totalPages){
        		this.curPage = this.totalPages;
        	}
        },
        submit:function(){
			// 查询提交
        	this.search();
		},
		reset:function(){
			// 重置查询条件
		}
	},
	computed: {
    	start:function(){
    		// 开始条数
    		return (this.curPage -1) * this.pageRecords + (this.items.length > 0 ? 1 : 0);
    	},
    	end:function(){
    		// 结束条数
    		return (this.curPage -1) * this.pageRecords + this.items.length;
    	},
    	indexs: function(){
        	// 显示的页码
            var left = 1
            var right = this.totalPages
            var ar = [] 
            if(this.totalPages >= 11){
              if(this.curPage > 5 && this.curPage < this.totalPages - 4){
                      left = this.curPage - 5
                      right = this.curPage + 4
              }else{
                  if(this.curPage <= 5){
                      left = 1
                      right = 10
                  }else{
                      right = this.totalPages
                      left = this.totalPages - 9
                  }
              }
           }
          while (left <= right){
              ar.push(left)
              left ++
          }   
          return ar
       },
       disableLast: function(){
    	   // 是否禁用最后页按钮
            if(this.curPage == this.totalPages){
                return true
            }
            return false
       },
       disableFirst: function(){
    	   // 是否禁用第一页按钮
            if(this.curPage == 1){
                return true
            }
           return false
       }
	}
});    

appVue.search();


/**
 * 
 */
function checkBoxChange(){
	setTimeout(function(){
		var checked = $('.gradeX input[type=checkbox]:checked').length;
		var all = $('.gradeX input[type=checkbox]').length;
		if(checked == all && all != 0){
			$('#checkAll').prop('checked',true);
		}else{
			$('#checkAll').prop('checked',false);
		}
		//page.receiveValue = modalVue.ids.toString();
	},10);
}
$('#checkAll').change(function(){
	//modalVue.ids=[];
	$('.gradeX input[type=checkbox]').each(function(){
		modalVue.ids.$remove(this.value);
	});
	setTimeout(function(){
		if ($('#checkAll').is(":checked")){
			$('.gradeX input[type=checkbox]').click();
		}
		//page.receiveValue = modalVue.ids.toString();
	},10);
});
/**
 * 
 */
function clearAll(){
	$('#checkAll').prop('checked',false);
	modalVue.ids = [];
	//page.receiveValue = '';
};